package com.csdn.springbootmybatis.service.impl;

import com.csdn.springbootmybatis.mapper.PermissionMapper;
import com.csdn.springbootmybatis.mode.Account;
import com.csdn.springbootmybatis.mode.Permission;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: JLL
 * @Date: 2019/8/24 15:23
 */
@Service
public class PermissionService {

    @Resource
    private PermissionMapper permissionMapper;

    public PageInfo<Permission> findByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);

        List<Permission> list =  permissionMapper.selectAll();
        return new PageInfo<>(list,pageSize);
    }


    public Permission findById(int id) {

        return permissionMapper.selectByPrimaryKey(id);
    }

    public void add(Permission permission) {
        permissionMapper.insert(permission);
    }

    public void update(Permission permission) {
        permissionMapper.updateByPrimaryKeySelective(permission);
    }

    public List<Permission> findAll() {
        return permissionMapper.selectAll();
    }
}
